|
|
|
|
|
|
|
Note the use of the new dbFind control on the form. You need to add very little code to this project. Listing 12.24 shows the code for the Form_Load event. Add this to your project. |
|
|
|
|
|
|
|
|
Listing 12.24. Coding the Form_Load event. |
|
|
|
|
|
|
|
|
Private Sub Form_Load()
'
' set database control values
Data1.DatabaseName = "c:\tysdbvb5\source\data\books5.mdb"
Data1.RecordSource = "Authors"
'
' set field binding
Text1.DataField = "AUID"
Text2.DataField = "Name"
Text3.DataField = "DOB"
'
' set up dbfind control
dbFind1.DatabaseName = Data1.DatabaseName
dbFind1.RecordSource = "SELECT * FROM Authors ORDER BY Name"
dbFind1.BoundColumn = "AUID"
dbFind1.ListField = "Name"
dbFind1.Refresh
'
' some other nice stuff
Me.Caption = Data1.RecordSource
'
End Sub |
|
|
|
|
|
|
|
|
The code in Listing 12.24 sets up the data control properties, binds the text boxes to the Data1 control, and then sets up the dbFind1 control properties. You'll notice that the RecordSource for the dbFind1 control is the same data table used for the Data1 control. The only difference is that the dbFind1 control data set is sorted by Name. This means that when the user presses the Find button, the dbFind dialog displays the records in Name order. |
|
|
|
|
| |
|
|
|
|
Most of the code in Listing 12.24 repeats property settings that can be performed at design time. They are set here in order to show you how the Data1 and dbFind1 properties are closely related. |
|
|
|
|
|
|
|
|
|
|
The only other code you need in this form is a list of code in the dbFind1_Selected event that repositions the data pointer to display the record selected by the user. Add the following code to the dbfind1_Selected event: |
|
|
|
|
|